feat(config): exporter plugin loading via entry points for declarative config#5128
Open
MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
Open
feat(config): exporter plugin loading via entry points for declarative config#5128MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
SpanExporter, LogRecordExporter, and PushMetricExporter are changed from @DataClass to TypeAlias = dict[str, Any] in models.py, preserving unknown exporter names as dict keys through the config pipeline. Each signal's factory function (_create_span_exporter, _create_log_record_exporter, _create_push_metric_exporter) now has a registry of known exporter names (otlp_http, otlp_grpc, console) with fallback to load_entry_point for unknown names via the opentelemetry_{traces,logs,metrics}_exporter entry point groups. _parse_headers in _common.py is updated to handle both NameStringValuePair objects (typed config) and raw dicts (YAML path), making the full dict path testable end-to-end. Assisted-by: Claude Opus 4.6
The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so parent fields like BatchSpanProcessor.exporter naturally accept raw dicts (from the YAML loader) alongside typed instances. Tests updated to pass raw dicts consistently. Assisted-by: Claude Opus 4.6
Use typed SpanExporterConfig, LogRecordExporterConfig, and
PushMetricExporterConfig with additional_properties from the
@_additional_properties decorator instead of raw dict iteration.
Known exporter types are checked via typed fields and their
registries. Unknown plugin names from additional_properties are
loaded via the opentelemetry_{traces,logs,metrics}_exporter
entry point groups.
Assisted-by: Claude Opus 4.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends exporter support in declarative file configuration to handle custom (plugin) exporters across all three signals, matching the spec's PluginComponentProvider mechanism.
Depends on #5131 (
additional_propertiessupport for generated models).Solution
Each signal's factory function uses typed exporter config with
additional_properties:SpanExporterConfig_SPAN_EXPORTER_REGISTRYopentelemetry_traces_exporterPushMetricExporterConfig_METRIC_EXPORTER_REGISTRYopentelemetry_metrics_exporterLogRecordExporterConfig_LOG_EXPORTER_REGISTRYopentelemetry_logs_exporterKnown exporter types (
otlp_http,otlp_grpc,console) are checked via typed fields and their registries. Unknown plugin names fromadditional_propertiesare loaded via entry points.Custom exporter example
Remaining work
The OTLP factory functions still use typed attribute access (
config.endpoint, etc.) internally. Converting them to accept raw dicts from the YAML loader is tracked in #5127.Closes #5069